﻿<%@ Page Title="Edit Suppliers" Language="C#" MasterPageFile="~/Pages/admin/adminMaster.Master" AutoEventWireup="true" CodeBehind="EditSuppliers.aspx.cs" Inherits="WarehouseWebAPP.Pages.admin.Edit_Entities.EditSuppliers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1">
    <tr>
        <td>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:Label ID="ErrorLabel" runat="server" BackColor="#FFFFCC" 
                                ForeColor="Maroon" Height="24px" 
                                Text="Error: The entity can't be deleted from the following reason: This entity is a FK of other entity." 
                                Visible="False"></asp:Label>
                                    <asp:GridView ID="SuppliersGridView" runat="server" AllowPaging="True" 
                                        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                                        DataKeyNames="supplier_num" DataSourceID="SuppliersObjectDataSource" 
                                        ForeColor="#333333" GridLines="None" 
                                        onselectedindexchanged="SuppliersGridView_SelectedIndexChanged" PageSize="4" 
                                        Width="672px">
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <Columns>
                                            <asp:CommandField ShowSelectButton="True" />
                                            <asp:BoundField DataField="supplier_num" HeaderText="supplier_num" 
                                                ReadOnly="True" SortExpression="supplier_num" Visible="False" />
                                            <asp:BoundField DataField="supplier_name" HeaderText="Supplier Name" 
                                                SortExpression="supplier_name" />
                                            <asp:BoundField DataField="supplier_address" HeaderText="Address" 
                                                SortExpression="supplier_address" Visible="False" />
                                            <asp:BoundField DataField="supplier_phone" HeaderText="Phone No." 
                                                SortExpression="supplier_phone" />
                                            <asp:BoundField DataField="supplier_email" HeaderText="E-mail Address" 
                                                SortExpression="supplier_email" />
                                            <asp:BoundField DataField="supplier_contact_person" 
                                                HeaderText="Contact Person Name" SortExpression="supplier_contact_person" 
                                                Visible="False" />
                                            <asp:BoundField DataField="supplier_contact_phone" 
                                                HeaderText="Contact Person Phone" SortExpression="supplier_contact_phone" 
                                                Visible="False" />
                                        </Columns>
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:GridView>
                                    <br />
                                    <asp:DetailsView ID="SupplierDetailsView" runat="server" 
                                        AutoGenerateRows="False" CellPadding="4" DataKeyNames="supplier_num" 
                                        DataSourceID="SuppliersObjectDataSource" ForeColor="#333333" GridLines="None" 
                                        Height="50px" onitemdeleting="SupplierDetailsView_ItemDeleting" Width="496px">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <Fields>
                                            <asp:BoundField DataField="supplier_num" HeaderText="supplier_num" 
                                                SortExpression="supplier_num" Visible="False" />
                                            <asp:TemplateField HeaderText="Supplier Name" SortExpression="supplier_name">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="NameTextBox" runat="server" 
                                                        Text='<%# Bind("supplier_name") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                        ControlToValidate="NameTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                                        ControlToValidate="NameTextBox" ErrorMessage="Already Exist" 
                                                        onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("supplier_name") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="SupplierLabel" runat="server" 
                                                        Text='<%# Bind("supplier_name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="supplier_address" HeaderText="Address" 
                                                SortExpression="supplier_address" />
                                            <asp:TemplateField HeaderText="Phone No." SortExpression="supplier_phone">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("supplier_phone") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                        ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                                        ControlToValidate="TextBox2" ErrorMessage="Invalid Phone No." 
                                                        ValidationExpression="^0[23489]{1}(\-)?[^0\D]{1}\d{6}$|^0(5[012345678]){1}(\-)?\d{7}$"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("supplier_phone") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("supplier_phone") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="E-mail Address" SortExpression="supplier_email">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("supplier_email") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                                        ControlToValidate="TextBox3" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                                        ControlToValidate="TextBox3" ErrorMessage="Invalid E-mail" 
                                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("supplier_email") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("supplier_email") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="supplier_contact_person" 
                                                HeaderText="Contact Person Name" SortExpression="supplier_contact_person" />
                                            <asp:TemplateField HeaderText="Contact Person Phone" 
                                                SortExpression="supplier_contact_phone">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" 
                                                        Text='<%# Bind("supplier_contact_phone") %>'></asp:TextBox>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                                                        ControlToValidate="TextBox4" ErrorMessage="Invalid Phone No." 
                                                        ValidationExpression="^0[23489]{1}(\-)?[^0\D]{1}\d{6}$|^0(5[012345678]){1}(\-)?\d{7}$"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" 
                                                        Text='<%# Bind("supplier_contact_phone") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label4" runat="server" 
                                                        Text='<%# Bind("supplier_contact_phone") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                        </Fields>
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:DetailsView>
                                </ContentTemplate>
                            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>
            <asp:ObjectDataSource ID="SuppliersObjectDataSource" runat="server" DeleteMethod="SupplierDelete" 
                SelectMethod="SupplierGet" TypeName="WarehouseWebAPP.code.BLL.SupplierBLL" 
                UpdateMethod="SupplierUpdate">
                <UpdateParameters>
                    <asp:Parameter Name="supplier_name" Type="String" />
                    <asp:Parameter Name="supplier_address" Type="String" />
                    <asp:Parameter Name="supplier_phone" Type="String" />
                    <asp:Parameter Name="supplier_email" Type="String" />
                    <asp:Parameter Name="supplier_contact_person" Type="String" />
                    <asp:Parameter Name="supplier_contact_phone" Type="String" />
                    <asp:Parameter DbType="Guid" Name="supplier_num" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        </td>
    </tr>
</table>
</asp:Content>
